/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.begonza;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author bgonzales
 */
public class DataDictionary {

    private List<DataElement> dataElements;
    private String name;

    public DataDictionary() { init(); }

    public DataDictionary(String name)
    {
        init();
        this.name = name;    
    }

    private void init()
    {
        if ( null == dataElements )
        {
            dataElements = new ArrayList<DataElement>();
        }
    }

    public DataElement get(String name)
    {
        for (DataElement elem : dataElements )
        {
            if (name == elem.getName())
            {
                return elem;
            }
        }
        return null;
    }

    public DataElement add( DataElement e)
    {
        DataElement f = get(e.getName());
        if ( null == f )
        {
            dataElements.add(e);
            return e;
        }
        else
        {
            return null;    
        }
    }

    public DataElement get( int i)
    {
        DataElement e = dataElements.get(i);
        return e;
    }

    public List<DataElement> getDataElement() {
        return dataElements;
    }

    public void setDataElement(List<DataElement> dataElements) {
        this.dataElements = dataElements;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
